<!doctype html>
<html>
<head>
    <include file="public/head"/>
    <title>图形统计</title>
    <meta name="description" content="图形统计">
    <meta name="keywords" content="图形统计">
    <style>
        .none{
            display: none;
        }
        body {
            width: 95%;
            margin: 0px;
            padding: 0px;
        }
        html { overflow-x:hidden; }
    </style>
</head>
<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li class=""><a href="{:cmf_plugin_url('QbtGraphical://AdminIndex/index')}">配置中心</a></li>
        <li class=""><a href="{:cmf_plugin_url('QbtGraphical://AdminIndex/add')}">添加配置</a></li>
        <li class="active"><a >修改配置</a></li>
    </ul>
    <form method="post" class="js-ajax-form margin-top-20" action="{:cmf_plugin_url('QbtGraphical://AdminIndex/edit')}">
        <div class="table_list">
            <table  class="table table-hover">
                <tr>
                    <th>图形标题<span class="form-required" style="color: red">*</span></th>
                    <td>
                        <input class="form-control" type="text" name="post[title]" id="" required value="{$graphical['title']}" placeholder="请输入标题" />
                    </td>
                </tr>
                <tr>
                    <th>X轴标题(有关联的的带表别名)<span class="form-required" style="color: red">*</span></th>
                    <td>
                        <select class="form-control" name="post[x_axis_val]" id="x_axis_name" onchange="x_axis_names();">
                            <option value="0">请选择</option>
                            <option value="1" <eq name="graphical.x_axis_val" value="1" >selected</eq>>时间轴</option>
                            <option value="2" <eq name="graphical.x_axis_val" value="2" >selected</eq>>自定义标题</option>
                        </select>
                        <br/>
                        <select  class="form-control x_sel" name="post[x_axis_time]" style="display: none">
                            <option value="1" <eq name="graphical.x_axis_time" value="1" >selected</eq>>最近一周</option>
                            <option value="2" <eq name="graphical.x_axis_time" value="2" >selected</eq>>最近一个月</option>
                        </select>
                        <input type="text" value="{$graphical['x_axis_field']}" name="post[x_axis_field]" class="form-control x_sel" placeholder="请输入时间字段"/>
                        <br/>
                        <textarea class="form-control x_sec_text" type="text" name="post[x_axis_name]"  style="display: none"  required  placeholder="X轴标题(多个用英文逗号分隔)">{$graphical['x_axis_name']}</textarea>
                    </td>
                </tr>

                <tr>
                    <th>主表名(无需前缀)<span class="form-required" style="color: red">*</span></th>
                    <td>
                        <input class="form-control" type="text" name="post[table]"  required    value="{$graphical['table']}" placeholder=""/>
                    </td>
                </tr>
                <tr>
                    <th>条件<span class="form-required" style="color: red">如有关联字段名前+别名,主表a,附表b</span></th>
                    <td>
                        <input class="form-control" type="text" name="post[where]"      value="{$graphical['where']}" placeholder="(格式:['字段名'=>'字段值'])"/>
                    </td>
                </tr>
                <tr>
                    <th>统计名<span class="form-required"></span></th>
                    <td>
                        <textarea class="form-control" type="text" name="post[category_name]" placeholder="统计名">{$graphical['category_name']}</textarea>
                    </td>
                </tr>
                <tr>
                    <th>图表形状<span class="form-required"></span></th>
                    <td>
                        <select class="form-control" name="post[shape]" >
                            <option value="1" <eq name="graphical.shape" value="1" >selected</eq>>折线图</option>
                            <option value="2" <eq name="graphical.shape" value="2" >selected</eq>>柱状图</option>
                            <option value="3" <eq name="graphical.shape" value="3" >selected</eq>>饼图</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <th>是否生成新菜单<span class="form-required"></span></th>
                    <td>
                        <select class="form-control" name="post[is_menu]" onchange="is_menus()" id="is_menu" required>
                            <option value="0">请选择</option>
                            <option value="1" <eq name="graphical.is_menu" value="1" >selected</eq>>生成单独页面</option>
                            <option value="2" <eq name="graphical.is_menu" value="2" >selected</eq>>多个图形合并</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <th>菜单名称<span class="form-required" style="color: red">*</span></th>
                    <td>
                        <input class="form-control" type="text" name="post[name]"    id="name"   value="{$graphical['name']}" placeholder="菜单名称"/>
                    </td>
                </tr>
                <tr>
                    <th>是否关联<span class="form-required"></span></th>
                    <td>
                        <select class="form-control" id="join" name="post[is_join]" onchange="is_joins()">
                            <option value="0" <eq name="graphical.is_join" value="0" >selected</eq>>否</option>
                            <option value="1" <eq name="graphical.is_join" value="1" >selected</eq>>是</option>
                        </select>
                    </td>
                </tr>
                <tr class="none">
                    <th>主表关联ID<span class="form-required"></span></th>
                    <td>
                        <input class="form-control" type="text" name="post[main_table_id]"   value="{$graphical['main_table_id']}" placeholder="主表关联ID"/>
                    </td>
                </tr>
                <tr class="none">
                    <th>附表关联id<span class="form-required"></span></th>
                    <td>
                        <input class="form-control" type="text" name="post[assistant_table_id]"   value="{$graphical['assistant_table_id']}" placeholder="附表关联id"/>
                    </td>
                </tr>
                <tr class="none">
                    <th>附表(需要前缀)<span class="form-required"></span></th>
                    <td>
                        <input class="form-control" type="text" name="post[assistant_table]"   value="{$graphical['assistant_table']}" placeholder="附表名"/>
                    </td>
                </tr>
            </table>
            <input type="hidden" value="{$graphical['id']}" name="id" />
            <div class="form-group">
                <div class="col-sm-offset-4 col-sm-10">
                    <button type="submit" class="btn btn-primary js-ajax-submit">{:lang('SAVE')}</button>
                    <a class="btn btn-default" href="{:cmf_plugin_url('QbtGraphical://AdminIndex/index')}">{:lang('BACK')}</a>
                </div>
            </div>
        </div>
    </form>
</div>
<include file="public/scripts"/>
<script>
    is_joins();
    x_axis_names();
    is_menus();
    function is_joins() {
        var sec = $("#join  option:selected").val();
        if(sec==1){
            $('.none').show();
        }else {
            $('.none').hide();
        }
    }
    function x_axis_names(){
        var sec = $("#x_axis_name  option:selected").val();
        if(sec==1){
            $('.x_sel').show();
            $('.x_sec_text').hide();
        }else {
            $('.x_sec_text').show();
            $('.x_sel').hide();
        }
    }
    function is_menus(){
        var sec = $("#is_menu  option:selected").val();
        if(sec==1){
            $('#name').removeAttr('readonly')
        }else{
            $('#name').attr("readonly","readonly");
        }
    }
</script>
</body>
</html>